


const idCardRegex = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])\d{3}[0-9Xx]$/;

const phoneRegex = /^1[3-9]\d{9}$/;

function validateWithRegex(value, regex) {
  return regex.test(value);
}

let validatePass = (rule, value, callback) => {
  if (validateWithRegex(value,idCardRegex)) {
    callback();
  } else {
    callback(new Error('请输入正确的身份证号'));
  }
};
let validatePass1 = (rule, value, callback) => {
  if (validateWithRegex(value,phoneRegex)) {
    callback();
  } else {
    callback(new Error('请输入正确的手机号'));
  }
};

const layout = { rowNum: 5, columnNum: 1, rowGap: "1px", rowHeight:'100px', coliumnGap: "10px", labelCol: { span: 2 }, wrapperCol: { span: 6 }, }
const formRules = {
  name:[{ required: true, message: '请输入姓名', trigger: 'blur' },],
  cardNum:[{ required: true, message: '请输入身份证号', trigger: 'blur' }, { validator: validatePass, trigger: 'blur' }],
  phone:[{ required: true, message: '请输入实名手机号', trigger: 'blur' }, { validator: validatePass1, trigger: 'blur' } ], // { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  dw:[{ required: true, message: '请输入所属单位', trigger: 'blur' },],
  qd:[{ required: true, message: '请输入所属渠道', trigger: 'blur' },],
}

// 1内部员工；2渠道；3经营者
const optionList = [
  { label: '内部员工', value: '1' },
  { label: '渠道', value: '2', disabled: true  },
  { label: '经营者', value: '3', disabled: true },
]

const formDataList = [
  { enName:'name', cnName:'姓名', type:'input',value:'', numRowsOccupied: 1, numColumnOccupied: 1 ,formItemAttr:{},itemAttr:{placeholder:'请输入姓名'},optionList:[],isChangeEvent:false,},
  { enName:'cardNum', cnName:'身份证号', type:'input',value:'', numRowsOccupied: 1, numColumnOccupied: 1 ,formItemAttr:{},itemAttr:{placeholder:'请输入身份证号'},optionList:[],isChangeEvent:false,},
  { enName:'phone', cnName:'实名手机号', type:'input',value:'', numRowsOccupied: 1, numColumnOccupied: 1 ,formItemAttr:{},itemAttr:{placeholder:'请输入实名手机号'},optionList:[],isChangeEvent:false,},
  // { enName:'dw', cnName:'所属单位', type:'select',value:'', numRowsOccupied: 1, numColumnOccupied: 1 ,formItemAttr:{},itemAttr:{ placeholder:'请选择所属单位'},optionList:optionList,isChangeEvent:true,},
  // { enName:'qd', cnName:'所属渠道', type:'select',value:'', numRowsOccupied: 1, numColumnOccupied: 1 ,formItemAttr:{},itemAttr:{ placeholder:'请选择所属渠道'},optionList:optionList,isChangeEvent:false,},
]

const formConfig = () =>{
  return {
    layout,
    formRules,
    formDataList
  }
}

export default () => {
  return {...formConfig()}
}
